08. Trajectories
Trajectories
Now that we have a controller and it is flying simply waypoint missions, the next area of interest is flying trajectories, which is an area we have helped set up but will be leaving for you to explore!
We have provided a framework for reading in a trajectory file (see below for the file format) and a sample, very simple, straight line and back trajectory. In addition you will find a trajectory_flyer.py
file that contains the necessary class and script to test it out.
Go ahead and give it a try! You should see the same performance you saw with the straight line waypoint sets that are found in the velocity_flyer.py
and attitude_flyer.py
files. This is not unsurprising as if you look at the trajectory file itself, it is just about the same information.
Trajectory File Format
A trajectory file, as currently defined by the handler class, is a text file with each line being a trajectory point. Each line contains the following 4 pieces of information as comma separated values:
- relative time (in flight time in [s])
- north position (in [m])
- east position (in [m])
- down position (in [m])
Further Challenges
While the trajectory file we have provided you is a very simple one, it should be enough to get you started in the right direction to further explore the world of trajectories and explore the limits that you can take your Crazyflie!
To get you started, here are some small modifications ideas to get a feel for how trajectories can be of use:
Dynamic flights speeds. Using the same idea of a simple line, can you modify your trajectory file to do the return trip twice as quickly? How about starting and ending slowly but going quickly in the middle?
Altitude variation. Can you have your Crazyflie fly a pattern such as a sine wave in height while flying the line? Or how about always climbing quickly but descending slowly?
For those of you who are really ambitious, here are some ideas of how you might be able to extend the code provided:
Create your own complex trajectory files. How about flying a figure 8? How quickly can you get your Crazyflie to fly a given trajectory? How tight of turns, or how complex of trajectories can your controller handle?
Add attitude information to trajectory. Extend the trajectory handler and the file format to include attitude to each trajectory point. Can you successfully achieve specific attitudes at specific times during the flight?
Note: As you make more complicated trajectories, you may find that you will need to retune your controller to get the best performance you can out of the Crazyflie.